package as.util;

import java.util.ArrayList;
import java.util.List;

public class Page {
	public static int page(List sourceList, int size, int pageNo, List subList) {
		if(pageNo<1)pageNo=1;
		int totoalSize=sourceList.size();
		int maxPageNo= totoalSize/size+(totoalSize%size==0?0:1);
		int fromIndex=(pageNo-1)*size;
		if(fromIndex>totoalSize)
			fromIndex=totoalSize;
		
		int toIndex=pageNo*size<totoalSize?pageNo*size:totoalSize;
		subList.addAll(sourceList.subList(fromIndex, toIndex) );
		return maxPageNo;

	}
}
